package com.example.bus.ui.station;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.example.bus.databinding.FragmentStationBinding;

import java.util.List;

public class StationFragment extends Fragment {

    private Context context;

    private FragmentStationBinding stationBinding;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        StationViewModel stationViewModel =
                new ViewModelProvider(this).get(StationViewModel.class);

        stationBinding = FragmentStationBinding.inflate(inflater, container, false);


        context = getContext();


        //设置RecyclerView
        LinearLayoutManager linearLayoutManager = new GridLayoutManager(context,2);
        stationBinding.stationReV.setLayoutManager(linearLayoutManager);
        stationBinding.stationReV.setAdapter(new StationAdapter(context));


        View root = stationBinding.getRoot();
        return root;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        stationBinding = null;
    }
}